
import { DTaroAjax } from '@/http/http'
import http from '@/api/'
import commonUtils from '@/common/'
const base = '/api/cookcar-car'
const cookCarPath = '/cookCar'
const company = '/api/sys-authorize'  //sys-authorize/info/enterprise
const message = '/api/cookcar-msg'
const order = '/api/cookcar-order'
const cookCar = {
    // 寻车\车源公共接口
    // 删除寻车、车源
    delMySearchCar(params) {
        return DTaroAjax(`${base}${cookCarPath}/car/mySearchCarDelete`, params)
    },
    // 终止寻车、下架车源
    stopMySearchCarTakeOff(params) {
        return DTaroAjax(`${base}${cookCarPath}/car/mySearchCarTakeOff`, params)
    },
    // 发布寻车,车源
    commitReleaseCar(params) {
        return DTaroAjax(`${base}${cookCarPath}/car/releaseCar`, params, 'post')
    },

    // 我的车源接口
    // 获取我的车源列表-未过期
    getCarSourceList(params) {
        return DTaroAjax(`${base}${cookCarPath}/car/mySourceCarList`, params)
    },
    // 获取我的车源列表-已过期
    getCarSourceListTakeOff(params) {
        return DTaroAjax(`${base}${cookCarPath}/car/mySourceCarListTakeOff`, params)
    },
    // 我的车源-改价
    setMySourceCarChangePrice(params) {
        return DTaroAjax(`${base}${cookCarPath}/car/mySourceCarChangePrice`, params)
    },

    //车源详情
    getCarSourceDetail(params) {
        return DTaroAjax(`${base}${cookCarPath}/car/carSourceDetail`, params)
    },
    //寻车详情
    getCarSearchDetail(params) {
        return DTaroAjax(`${base}${cookCarPath}/car/carSearchDetail`, params)
    },
    // 我的寻车接口
    // 获取我的寻车列表-未过期
    getMySearchCarList(params) {
        return DTaroAjax(`${base}${cookCarPath}/car/mySearchCarList`, params)
    },
    // 获取我的寻车列表-已过期
    getMySearchCarListTakeOff(params) {
        return DTaroAjax(`${base}${cookCarPath}/car/mySearchCarListTakeOff`, params)
    },
    // 企业相关接口
    //企业详情
    getEnterpriseDetail(params) {
        return DTaroAjax(`${company}/info/enterprise/getEntInfo`, params)
    },
    //企业简介
    editEntryPriseintro(params) {
        return DTaroAjax(`${company}/info/enterprise/entIntroduction`, params)
    },
    //企业车源信息
    getenterList(params) {
        return DTaroAjax(`${base}${cookCarPath}/car/carSourceList`, params, 'post')
    },
    //互动通知消息获取
    getMessageList(params) {
        return DTaroAjax(`${message}/api/common/app/list`, params)
    },
    //发起订金担保
    async getEarnestForm(params) {
        // params = {pat:123,id:2}

        let par = params.orEarnestPrice
        // let jsonStr = JSON.stringify(params)
        let res = await http.keyInitInit()
        // alert(res)
        let paramsEnt = commonUtils.encryptResult(res, par)
        params.orEarnestPriceStr = paramsEnt
        // alert(paramsEnt)
        return DTaroAjax(`${order}/order/transCar/save`, params, 'post')
    },

    //发布寻车、车源
    addReleaseCar(params) {
        return DTaroAjax(`${base}/cookCar/car/releaseCar`, params, 'post')
    },

    // 发布报价
    addUserMoney(params) {
        return DTaroAjax(`${base}/cookCar/quoted/initiateQuoted`, params)
    },
    //车辆报价
    getCarQuoteList(params) {
        return DTaroAjax(`${base}/cookCar/quoted/myCarQuotedList`, params)
    },
    //修改车辆报价
    changeMycarquote(params) {
        return DTaroAjax(`${base}/cookCar/quoted/myCarQuotedChangePrice`, params)
    },
    //撤回车辆报价
    takeOffMycarQuote(params) {
        return DTaroAjax(`${base}/cookCar/quoted/myCarQuotedTakeOff`, params)
    },
    //删除我的报价
    delMycarQuote(params) {
        return DTaroAjax(`${base}/cookCar/quoted/myCarQuotedDelete`, params)
    },

    // 企业详情中寻车信息
    carSourceListByEnt(params) {
        return DTaroAjax(`${base}${cookCarPath}/car/searchCarList`, params, 'post')
    },

    // 获取订单数量
    getCorpTradeOrderCount(entId) {
        return DTaroAjax(`${order}/order/transCar/getCorpTradeOrderCount?corpId=${entId}`, {})
    },
    getCorpTransportOrderCount(entId) {
        return DTaroAjax(`${order}/trans/getCorpTransportOrderCount?corpId=${entId}`, {})
    }
}

export default cookCar
